export default class HisHistory {
  constructor(router) {
    this.router = router
    window.addEventListener('popstate', e => {
      this.transitionTo()
    })
  }
  getHash() {
    return location.pathname
  }

  transitionTo(callback) {
    const hash = this.getHash()
    this.router.matcher.match(hash)
    callback?.()
  }

  push(path) {
    history.pushState({}, '', path)
    this.transitionTo()
  }
}
